export enum ERecorderOperation {
  /** 无状态*/
  none = 'none',
  /** 回退*/
  backspacing = 'backspacing',
  /** image上传*/
  image = 'image',
  /** 刷子*/
  brush = 'brush',
  /** 文本*/
  text = 'text',
  /**直线 */
  line = 'line',
  /** 三角形*/
  triangle = 'triangle',
  /** 长方型*/
  rectangle = 'rectangle',
  /** 圆形*/
  circle = 'circle',
}

/**绘图 功能 */
export enum EGraph {
  /**直线 */
  line = 'line',
  /** 三角形*/
  triangle = 'triangle',
  /** 长方型*/
  rectangle = 'rectangle',
  /** 圆形*/
  circle = 'circle',
}

/**线颜色 */
export enum ERecorderBrashColor {
  black = '#20222E',
  red = '#F44522',
  yellow = '#FFD600',
  green = '#10CE8F',
  blue = '#4487FA',
}

/**录屏操作 */
export enum ERecorderStatus {
  none = 'none',
  start = 'start',
  stop = 'stop',
  pause = 'pause',
  restart = 'restart',
}

/**Recorder原始操作 */
export enum ERecorderBaseStatus {
  inactive = 'inactive',
  recording = 'recording',
  paused = 'paused',
}

/** 列表操作 */
export enum EOpButton {
  /**复制短链接 */
  copyLink = 'copyLink',
  /**保存显示qrcode */
  saveQRCode = 'saveQRCode',
  /**修改标题 */
  changeTitle = 'changeTitle',
  /**删除视频 */
  delete = 'delete',
}
/**视频编号 */
export type RecordVideoID = number
/**录制时间 */
export type RecordTime = number

/**异步器 */
export type CollPromiseObj<T> = {
  promiseObj: Promise<T>
  resolve: (value: T) => void | undefined
  reject: (value: string) => void | undefined
  execTime: number
}
/**
 * 异步控制器
 * @returns 控制对象
 */
export const createPromiseObj: <T>() => CollPromiseObj<T> = <T>() => {
  let resolve: ((value: T) => void) | undefined
  let reject: ((reason: any) => void) | undefined
  const uploadPromiseObj = {
    promiseObj: new Promise((res: ((value: T) => void) | undefined, rej) => {
      resolve = res
      reject = rej
    }),
    resolve: (value: T) => {},
    reject: (value: any) => {},
    execTime: +new Date(),
  }
  uploadPromiseObj.resolve = resolve!
  uploadPromiseObj.reject = reject!
  return uploadPromiseObj
}
